/* === Safari-style Fake Browser Bar (with glass effect) === */

.fake-safari-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 48px;
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  background: var(--bar-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  border-bottom: 1px solid var(--bar-border);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
  z-index: 1000;
  user-select: none;
  -webkit-user-select: none;
  transition:
    transform 0.35s ease,
    height 0.25s ease,
    opacity 0.3s ease,
    backdrop-filter 0.3s ease,
    -webkit-backdrop-filter 0.3s ease;
  will-change: transform, height, opacity;
  display: none; /* hidden by default — shown only in PWA */
}

/* Show bar only in PWA mode */
body.standalone .fake-safari-bar {
  display: flex;
}

/* Compact mode (shrinks before hiding) */
.fake-safari-bar.compact {
  height: 36px;
  backdrop-filter: saturate(160%) blur(18px);
  -webkit-backdrop-filter: saturate(160%) blur(18px);
}

/* Hidden state (slides up and fades out) */
.fake-safari-bar.hide {
  transform: translateY(-100%);
  opacity: 0;
}

.fake-safari-bar:not(.hide) {
  animation: bar-bounce 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* URL field container */
.fake-safari-url {
  background: var(--url-bg);
  border-radius: 12px;
  padding: 6px 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  width: 90%;
  max-width: 420px;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

/* Compact mode animation */
.fake-safari-bar.compact .fake-safari-url {
  opacity: 0.85;
  transform: scale(0.98);
}

/* Icon (padlock) */
.padlock {
  width: 16px;
  height: 16px;
  fill: var(--icon-color);
  flex-shrink: 0;
}

/* URL text — truncates gracefully */
.url-text {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 13px;
  color: var(--url-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

/* Add top padding so content isn’t hidden under bar */
body {
  padding-top: 48px;
  background: var(--page-bg);
  margin: 0;
}

/* === Gradient fade overlay (appears when bar hides) === */
.fake-safari-fade {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 32px;
  pointer-events: none;
  backdrop-filter: saturate(180%) blur(18px);
  -webkit-backdrop-filter: saturate(180%) blur(18px);
  background: var(--fade-start);
  opacity: 0;
  transition: opacity 0.35s ease;
  z-index: 999;
  display: none; /* hidden unless in PWA */
}

/* Show fade only in PWA mode */
body.standalone .fake-safari-fade {
  display: block;
}

/* When bar hides, fade in overlay */
.fake-safari-bar.hide ~ .fake-safari-fade {
  opacity: 1;
}

@keyframes bar-bounce {
  0% {
    transform: translateY(-100%);
  }
  60% {
    transform: translateY(6%);
  }
  80% {
    transform: translateY(-2%);
  }
  100% {
    transform: translateY(0);
  }
}

/* === Color Themes === */
@media (prefers-color-scheme: light) {
  :root {
    --bar-bg: rgba(249, 249, 250, 0.85);
    --bar-border: rgba(0, 0, 0, 0.05);
    --url-bg: rgba(255, 255, 255, 0.8);
    --icon-color: #555;
    --url-text: #333;
    --page-bg: #ffffff;
    --fade-start: linear-gradient(to bottom, rgba(249, 249, 250, 0.85), transparent);
  }
}

@media (prefers-color-scheme: dark) {
  :root {
    --bar-bg: rgba(28, 28, 30, 0.75);
    --bar-border: rgba(255, 255, 255, 0.08);
    --url-bg: rgba(44, 44, 46, 0.8);
    --icon-color: #aaa;
    --url-text: #e5e5e7;
    --page-bg: #000000;
    --fade-start: linear-gradient(to bottom, rgba(28, 28, 30, 0.75), transparent);
  }
}
